package com.jfinal.complex.tablesplit.impl;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.jfinal.complex.exception.TableSplitException;
import com.jfinal.complex.tablesplit.interfaces.ITableSplitConverter;

/**
 * 默认日期转yyyyMM格式字符串转换器
 * @author yuehh
 *
 */
public class DateYyyymmConverter implements ITableSplitConverter {
	private static DateFormat df = new SimpleDateFormat("yyyyMM");
	public String convert(Object target) {
		if(target!=null && target instanceof Date){
			return df.format((Date)target);
		}else{
			throw new TableSplitException("转换对象为null或者不是一个java.util.Date对象");
		}
	}
}
